// components/textKey.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    innerText: {
      type: String,
      value: '',
    },
    tableName:{
      type: String,
      value: '',
    }
  },
  lifetimes: {
    attached() {
      this.parseTxt();
    },
  },
  /**
   * 组件的初始数据
   */
  data: {
    txtArray:[]
  },

  /**
   * 组件的方法列表
   */
  methods: {
    // 字符串高亮显示
    parseTxt(){
      let {innerText:str} = this.data;
      //str = str.replace(/^(([^ 0][0 - 9] + | 0) \.([0 - 9]{1,2}) $) | ^(^[0][0 - 9] + | 0)/,"、$&、")
      let str2 = str.replace(/([0-9]+\.[0-9]{1,3})|([0-9]+)/ig,"|$&|")
      let tArayy=str2.split('|');
      let txtArray = tArayy.map((el) =>{
        let sj = {}
        if(/([0-9]+\.[0-9]{1,3})|([0-9]+)/.test(el)){
          sj = {txt:el,cl:'gaoliang'}
        }else{
          sj = {txt:el,cl:''}
        }
        return sj
      });
      this.setData({txtArray})
    },
    // 跳转列表
    lookCloumns(e) {
      let { tableName } = this.data;
      wx.setStorageSync('TABLE_NAME', tableName);
      wx.navigateTo({
          url: '/pages/tableDetail/index',
      })
  },
  }
})
